import { Controller, Get, Post, Patch, Body, Param, Delete, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Limit } from '@common/utils/constants';
import { OrderCreateDto, OrderListDto, OrderUpdateDto } from './dto';
import { OrderService } from './order.service';

@ApiTags('order')
@ApiBearerAuth()
@Controller()
export class OrderController {
    constructor(private readonly orderService: OrderService) {}
    /**
     * 新增订单表
     */
    @ApiOperation({ summary: '新增订单表' })
    @Post('/order/create')
    create(@Body() createOrderDto: OrderCreateDto) {
        return this.orderService.create(createOrderDto);
    }
    /**
     * 订单表列表（query）
     */
    @ApiOperation({ summary: '订单表列表（query）' })
    @Post('/order/list')
    queryList(@Body() dto: OrderListDto) {
        return this.orderService.list(dto);
    }
    /**
     * 订单表列表
     */
    @ApiOperation({ summary: '订单表列表' })
    @Get('/order/list')
    list(@Query() limit: Limit) {
        return this.orderService.list({ limit });
    }
    // @Get('/order')
    // findAll() {
    //     return this.orderService.findAll();
    // }
    /**
     * 订单表详情
     */
    @Get('/order/details/:id')
    @ApiOperation({ summary: '某个订单表信息' })
    @ApiResponse({
        status: 200,
        // description: 'The found record',
        // type: GetOrderInfoResult,
    })
    details(@Param('id') id: number) {
        return this.orderService.findById(id);
    }
    /**
     * 修改订单表
     */
    @Patch('/order/update/:id')
    @ApiOperation({ summary: '修改订单表信息' })
    update(@Param('id') id: number, @Body() updateOrderDto: OrderUpdateDto) {
        return this.orderService.update(id, updateOrderDto);
    }
    /**
     * 删除订单表
     */
    @ApiOperation({ summary: '删除订单表' })
    @Delete('/order/remove/:id')
    remove(@Param('id') id: number) {
        return this.orderService.delete(id);
    }
}
